{#**
 * 2007-2020 PrestaShop SA and Contributors
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Open Software License (OSL 3.0)
 * that is bundled with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * https://opensource.org/licenses/OSL-3.0
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@prestashop.com so we can send you a copy immediately.
 *
 * DISCLAIMER
 *
 * Do not edit or add to this file if you wish to upgrade PrestaShop to newer
 * versions in the future. If you wish to customize PrestaShop for your
 * needs please refer to https://www.prestashop.com for more information.
 *
 * @author    PrestaShop SA <contact@prestashop.com>
 * @copyright 2007-2020 PrestaShop SA and Contributors
 * @license   https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
 * International Registered Trademark & Property of PrestaShop SA
 *#}

  {{ form_start(updateOrderStatusActionBarForm, {
    'action': path('admin_orders_update_status', {'orderId': orderForViewing.id}),
    'attr': {
      'id': 'update_order_status_action_form'
    }
  }) }}

  <div class="input-group">
    {% set backgroundColor = '#ffffff' %}
    {% set isBright = true %}
    {% for choice in updateOrderStatusActionBarForm.new_order_status_id.vars.choices %}
      {% if choice.value == updateOrderStatusActionBarForm.new_order_status_id.vars.data %}
        {% set backgroundColor = choice.attr['data-background-color'] %}
        {% set isBright = choice.attr['data-is-bright'] %}
      {% endif %}
    {% endfor %}
    <div class="select-status{% if isBright %} is-bright{% endif %}" id="update_order_status_action_input_wrapper" style="background-color:{{ backgroundColor }};">
        {{ form_widget(updateOrderStatusActionBarForm.new_order_status_id, {
          'attr': {
            'class': 'select-status-colored',
          },
          'id': 'update_order_status_action_input',
        }) }}
    </div>

    <button class="btn btn-action ml-2"
            id="update_order_status_action_btn"
            disabled
            data-order-status-id="{{ orderForViewing.history.currentOrderStatusId }}"
    >
      {{ 'Update status'|trans({}, 'Admin.Orderscustomers.Feature') }}
    </button>
  </div>

  <div class="d-none">
    {{ form_rest(updateOrderStatusActionBarForm) }}
  </div>
  {{ form_end(updateOrderStatusActionBarForm) }}

  {% if orderForViewing.documents.canGenerateInvoice %}
    <form class="order-actions-invoice">
      <div class="input-group">
        <a href="{{ path('admin_orders_generate_invoice_pdf', {'orderId': orderForViewing.id}) }}"
           class="btn btn-action">
          <i class="material-icons">receipt</i>
          {{ 'View invoice'|trans({}, 'Admin.Orderscustomers.Feature') }}
        </a>
      </div>
    </form>
  {% endif %}

  <form class="order-actions-print">
    <div class="input-group">
      <button type="button" class="btn btn-action js-print-order-view-page">
        <i class="material-icons" aria-hidden="true">print</i>
        {{ 'Print order'|trans({}, 'Admin.Orderscustomers.Feature') }}
      </button>
    </div>
  </form>

  {% if orderForViewing.documents.canGenerateDeliverySlip %}
    <form class="order-actions-delivery">
      <div class="input-group">
        <a href="{{ path('admin_orders_generate_delivery_slip_pdf', {'orderId': orderForViewing.id}) }}"
           class="btn btn-action">
          <i class="material-icons">local_shipping</i>
          {{ 'View delivery slip'|trans({}, 'Admin.Orderscustomers.Feature') }}
        </a>
      </div>
    </form>
  {% endif %}

  {% include '@PrestaShop/Admin/Sell/Order/Order/Blocks/View/extra_order_button_actions.html.twig' %}

  {% if merchandiseReturnEnabled %}
    {% if orderForViewing.isDelivered() %}
      <button class="btn btn-action return-product-display" type="button"{% if not orderForViewing.isRefundable() %} disabled{% endif %}>
        <i class="material-icons">swap_horiz</i>
        {{ 'Return products'|trans({}, 'Admin.Orderscustomers.Feature') }}
      </button>
    {% elseif orderForViewing.hasBeenPaid() or orderForViewing.hasPayments() %}
      <button class="btn btn-action standard-refund-display" type="button"{% if not orderForViewing.isRefundable() %} disabled{% endif %}>
        <i class="material-icons">swap_horiz</i>
        {{ 'Standard refund'|trans({}, 'Admin.Orderscustomers.Feature') }}
      </button>
    {% else %}
      <button class="btn btn-action cancel-product-display" type="button">
        {{ 'Cancel products'|trans({}, 'Admin.Orderscustomers.Feature') }}
      </button>
    {% endif %}
  {% endif %}

  {% if orderForViewing.hasBeenPaid() or orderForViewing.hasPayments() %}
      <button class="btn btn-action partial-refund-display" type="button"{% if not orderForViewing.isRefundable() %} disabled{% endif %}>
        <i class="material-icons">swap_horiz</i>
        {{ 'Partial refund'|trans({}, 'Admin.Orderscustomers.Feature') }}
      </button>
  {% endif %}

  {% include '@PrestaShop/Admin/Sell/Order/Order/Blocks/View/order_navigation.html.twig' %}
